Skip to content

refactor(pg/catalog): use explicit pretty bool for view-def getters#311

Open
h3n4l wants to merge 1 commit into
mainfrom
claude/compassionate-lamport-33384b
Open

refactor(pg/catalog): use explicit pretty bool for view-def getters#311
h3n4l wants to merge 1 commit into
mainfrom
claude/compassionate-lamport-33384b

Conversation

@h3n4l

@h3n4l h3n4l commented Jun 17, 2026

Copy link
Copy Markdown
Member

What

Catalog.GetViewDefinition and Catalog.GetMatViewDefinition took pretty ...bool. The variadic existed only to make the flag optional (Go has no default arguments) — the body just read pretty[0] and defaulted to false.

In practice every one of the ~10 call sites omitted the argument and relied on that default; none ever requested pretty output. The variadic also weakens the contract: GetViewDefinition(s, n, true, false) compiles and silently ignores the extra bool, with no compile-time arity check.

This switches both methods to an explicit pretty bool and updates all callers to pass false.

Why

  • Precise signature: exactly one bool, can't pass zero or several.
  • More self-documenting / discoverable at call sites.
  • No behavior change — pretty=false was already the universal default.

Changes

  • pg/catalog/ruleutils.gopretty ...boolpretty bool on both getters; drop the len(pretty) > 0 unwrap.
  • Call sites updated to pass false: migration_view.go (5), diff_view.go (2), migration.go (1), phase4_analyze_test.go (1), phase5_types_test.go (1).

Verification

go build, go vet, and go test ./pg/catalog/... all pass.

🤖 Generated with Claude Code

GetViewDefinition / GetMatViewDefinition took `pretty ...bool` solely to
make the flag optional (Go has no default arguments). But every caller
relied on the default and none ever passed a value, and the variadic
silently accepts more than one bool with no compile-time arity check.

Switch both to an explicit `pretty bool` and update all call sites to
pass `false`. No behavior change; the signature is now precise.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@h3n4l h3n4l force-pushed the claude/compassionate-lamport-33384b branch from 8b2a026 to 34687b7 Compare June 22, 2026 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant